# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=cmark
pkgver=0.30.3
pkgrel=2
pkgdesc="C reference implementation of CommonMark, a rationalized Markdown spec"
url="https://github.com/commonmark/cmark"
arch="all"
license="BSD-2-Clause"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	$pkgname-static=$pkgver-r$pkgrel
	"
makedepends="
	cmake
	re2c
	samurai
	"
checkdepends="python3"
subpackages="$pkgname-doc $pkgname-static $pkgname-dev lib$pkgname:libs"
source="https://github.com/commonmark/cmark/archive/$pkgver/cmark-$pkgver.tar.gz"

# secfixes:
#   0.30.3-r0:
#     - CVE-2023-22486

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
27383bfef95ae1390c26aff0dd2cbca33704e7d20116bf29da4695d2c9a4146b86daba0da1e91bdb9eab95671702f885e832b3d31d51601731f1dc630df5237b  cmark-0.30.3.tar.gz
"
